﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Baosight.ZNH.ZMCommon;
using Baosight.Platform.Core;
using Baosight.Platform.Core.ServiceModel;
using Baosight.Platform.Core.UI.Controls;
using Telerik.Windows.Controls;
using Baosight.ZNH.ZMCommon.ChildWindows;
using Baosight.ZNH.ZMCM.UI.Utils;
using Telerik.Windows.Controls.GridView;
using Baosight.ZNH.ZMCommon.Validators;
using System.Collections.ObjectModel;


namespace Baosight.ZNH.ZMCM.UI
{
    /// <summary>
    /// 初始数据主表  
    /// </summary>
    /// Title:ZMCM82
    /// Copyright:Baosight Software LTD.co Copyright (c) 2011
    /// Company:上海宝信软件股份有限公司
    /// Author: 张坤
    /// Version: 1.0
    /// History:
    ///       2010-12-14  张坤   [创建]
    ///
    public partial class ZMCM82 : EFViewCmes
    {
        private MonthBlock monthblock = new MonthBlock();//构造前台下拉列表
        public ZMCM82()
        {
            InitializeComponent();
            base.Mode = OperationMode.Insert;
        }

        public override void Initialize(EIInfo initData)
        {
            initData.AddBlock(monthblock.GetMonth());
            base.Initialize(initData);
            this.fdEditor.Value = initData.Get("userName");
            this.fdApplicationDepartmentName.Value = initData.Get("orgName");//名称
            this.fdApplicationDepartment.Value = initData.Get("departmentId"); //ID
            this.fdApplicationDate.Value = System.DateTime.Now.Date;
            this.fdYear.Value = System.DateTime.Now.Year;
            this.fdMonth.Value = System.DateTime.Now.Month.ToString();
            this.fdApplicationCode.Value = initData.Get("fdApplicationCode");
            if ("0".Equals(initData.Get("IsuseNoplanApplication").ToString()))
            {
                this.NoPlanNext.Visibility = Visibility.Collapsed;
                this.Next.Content = "下一步";
            }
            else
            {
                this.NoPlanNext.Visibility = Visibility.Visible;
                this.Next.Content = "下一步(计划领料)";
            }
        }

        /// <summary>
        /// 执行下一步(无计划领料)操作动作
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void NoPlanNext_Click(object sender, RoutedEventArgs e)
        {
            if (this.ValidateField())
            {
                base.OnQueryButtonClick(sender, e);
                if (this.RESULT.Visibility == Visibility.Collapsed && this.Reported.Visibility == Visibility.Collapsed
                    && this.Saved.Visibility == Visibility.Collapsed && this.Cancel.Visibility == Visibility.Collapsed
                    && this.InsertGrid1.Visibility == Visibility.Collapsed)
                {
                    //隐藏上帧页面
                    //this.View.Visibility = Visibility.Collapsed;
                    this.InsertGrid.Visibility = Visibility.Collapsed;
                    this.Next.Visibility = Visibility.Collapsed;
                    this.Return.Visibility = Visibility.Collapsed;

                    //展示下帧页面
                    this.InsertGrid1.Visibility = Visibility.Visible;
                    this.NOPLANRESULT.Visibility = Visibility.Visible;
                    this.DETAILS.Visibility = Visibility.Visible;
                    this.Save.Visibility = Visibility.Visible;
                    this.Clear.Visibility = Visibility.Visible;
                    this.Last.Visibility = Visibility.Visible;
                    this.Saved.Visibility = Visibility.Visible;
                    this.Reported.Visibility = Visibility.Visible;
                    this.Cancel.Visibility = Visibility.Visible;
                }
            }
        }

        /// <summary>
        /// 执行下一步操作动作
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Next_Click(object sender, RoutedEventArgs e)
        {
            if (this.ValidateField())
            {
                base.OnQueryButtonClick(sender, e);
                if (this.RESULT.Visibility == Visibility.Collapsed && this.Reported.Visibility == Visibility.Collapsed
                    && this.Saved.Visibility == Visibility.Collapsed && this.Cancel.Visibility == Visibility.Collapsed
                    && this.InsertGrid1.Visibility == Visibility.Collapsed)
                {
                    //隐藏上帧页面
                    //this.View.Visibility = Visibility.Collapsed;
                    this.InsertGrid.Visibility = Visibility.Collapsed;
                    this.Next.Visibility = Visibility.Collapsed;
                    this.Return.Visibility = Visibility.Collapsed;

                    //展示下帧页面
                    this.InsertGrid1.Visibility = Visibility.Visible;
                    this.INQU.Visibility = Visibility.Visible;
                    this.RESULT.Visibility = Visibility.Visible;
                    this.Last.Visibility = Visibility.Visible;
                    this.Saved.Visibility = Visibility.Visible;
                    this.Reported.Visibility = Visibility.Visible;
                    this.Cancel.Visibility = Visibility.Visible;
                }
            }
        }

        /// <summary>
        /// “删除”链接
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DeleteButton_Click(object sender, RoutedEventArgs e)
        {
            base.TempHyperlink = sender as HyperlinkButton;
            DialogParameters param = this.ModelDialogParameters("Confirm", "确定删除所选择的记录？");
            param.Closed = DeleteConfirmClosed;
            EFWindow.Confirm(param);
        }

        /// <summary>
        /// 点击确认按钮执行事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DeleteConfirmClosed(object sender, WindowClosedEventArgs e)
        {
            if (e.DialogResult == null)
            {
                return;
            }
            if (e.DialogResult.Value)
            {
                EIRow row = (base.TempHyperlink.ParentOfType<GridViewRow>().Item as UIBaseEntity).GetEIRow();
                this.noplansub_grid.EIBlock.Rows.Remove(row);
            }
        }

        /// <summary>
        /// “确定”按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Save_Click(object sender, RoutedEventArgs e)
        {
            //按钮不可用，防止双击
            Button button = sender as Button;
            button.IsEnabled = false;
            TempButton = button;


            bool result = false;

            //ValidatorManager自定义的校验方法
            ValidatorManager group = this.GetChildObject<ValidatorManager>(null);
            if (group != null)
            {
                result = group.IsValidSucces;
            }

            bool _validateField = result;//确定前的效验

            if (!_validateField)
            {
                this.ValidateMessagePopup();//弹出提示信息
                this.TempButtonOpen(true);//确定按钮生效
            }
            else
            {
                String code = this.fdMaterialCode.Value.ToString();
                int count = this.noplansub_grid.EIBlock.GetRowCount();
                foreach (EIRow code_row in this.noplansub_grid.EIBlock.GetRows())
                {
                    if (code.Equals(code_row["fdMaterialCode"].ToString()))
                    {
                        base.OpenEFWindowAlert("物资编码重复，请重新选择物资编码！", true);
                        this.TempButtonOpen(true);
                        return;
                    }
                }

                EIRow row = new EIRow();
                foreach (var _field in this.DETAILS.GetChildObjects<EFDataField>(null, true))
                {
                    row.Add(_field.eBindingName, _field.Value);
                }
                this.noplansub_grid.EIBlock.AddRow(row);

                //保存后，清空文本框信息
                foreach (var field in this.DETAILS.GetChildObjects<EFDataField>(null, true))
                {
                    if (!field.Name.Equals("fdApplicationType"))
                    {
                        field.SetDataValue("");
                    }
                    if (field.Name.Equals("fdMaterialCode"))//如果是公共选择则重新获得对象
                    {
                        CmesCustomView picker = field.Content as CmesCustomView;
                        picker.ItemObject = "";
                    }
                }
                if (group != null)
                {
                    group.InValidateAll();
                }

                this.TempButtonOpen(true);//确定按钮生效
            }

        }

        /// <summary>
        /// “清空”按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Clear_Click(object sender, RoutedEventArgs e)
        {
            foreach (var field in this.DETAILS.GetChildObjects<EFDataField>(null, true))
            {
                if (!field.Name.Equals("fdApplicationType"))
                {
                    field.SetDataValue("");
                }
                if (field.Name.Equals("fdMaterialCode"))//如果是公共选择则重新获得对象
                {
                    CmesCustomView picker = field.Content as CmesCustomView;
                    picker.ItemObject = "";
                }

            }
            //清除列表值得时候设置校验为无效
            ValidatorManager group = this.GetChildObject<ValidatorManager>(null);
            if (group != null)
            {
                group.InValidateAll();
            }
        }

        private void Last_Click(object sender, RoutedEventArgs e)
        {
            //隐藏上帧页面
            //this.View.Visibility = Visibility.Visible;
            this.InsertGrid.Visibility = Visibility.Visible;
            this.Next.Visibility = Visibility.Visible;
            this.Return.Visibility = Visibility.Visible;

            //展示下帧页面
            this.InsertGrid1.Visibility = Visibility.Collapsed;
            this.INQU.Visibility = Visibility.Collapsed;
            this.RESULT.Visibility = Visibility.Collapsed;
            this.NOPLANRESULT.Visibility = Visibility.Collapsed;
            this.DETAILS.Visibility = Visibility.Collapsed;
            this.Save.Visibility = Visibility.Collapsed;
            this.Clear.Visibility = Visibility.Collapsed;
            this.Last.Visibility = Visibility.Collapsed;
            this.Saved.Visibility = Visibility.Collapsed;
            this.Reported.Visibility = Visibility.Collapsed;
            this.Cancel.Visibility = Visibility.Collapsed;
        }

        private void Return_Click(object sender, RoutedEventArgs e)
        {
            CmesWindows _window = this.Parent as CmesWindows;
            _window.DialogResult = false;
            _window.Close();
        }

        /// <summary>
        /// 执行保存动作
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Saved_Click(object sender, RoutedEventArgs e)
        {
            Button button = sender as Button;
            button.IsEnabled = false;
            TempButton = button;
            String msg = "1";
            IList<EIRow> _list = this.sub_grid.GetCheckedEIRows() == null ? new List<EIRow>() : this.sub_grid.GetCheckedEIRows();
            IList<EIRow> noplan_list = null;
            if (this.noplansub_grid.EIBlock != null)
            {
                noplan_list = this.noplansub_grid.EIBlock.GetRows();
            }

            if (this.LessMoney.Value.ToString() == "0")
            {
                msg = "用户已经无材料费用额度，请通知相关部门调整费用额度！";
            }
            else if (this.RESULT.Visibility == Visibility.Visible && _list.Count <= 0)
            {
                msg = "请选择需要申请上报的数据明细！";
            }
            else if (this.NOPLANRESULT.Visibility == Visibility.Visible && noplan_list.Count <= 0)
            {
                msg = "请增加领料申请数据明细！";
            }
            //else if(this.RESULT.Visibility == Visibility.Visible)
            //{
            //    for (int i = 0; i < _list.Count; i++)
            //    {
            //        if (this.sub_grid.GetCheckedEIRows()[i]["fdApplyProject"] != null)
            //        {
            //            if (this.sub_grid.GetCheckedEIRows()[i]["fdApplyProject"].ToString() == "")
            //            {
            //                msg = "请选择适用工程！";
            //                break;
            //            }
            //        }
            //        else
            //        {
            //            msg = "请选择适用工程！";
            //            break;
            //        }
            //    }
            //}

            if (msg == "1")
            {
                if (this.RESULT.Visibility == Visibility.Visible)
                {
                    this.fdApplicationStatus.Value = "草拟";
                    base.Submit(OperationMode.Insert, "ZMCM82", "insert", DataRange.CheckedItems, DoCommitCompleted, null);
                }
                else
                {
                    this.fdApplicationStatus.Value = "草拟";
                    EIInfo eiInfo = new EIInfo();
                    eiInfo.Set("service", "ZMCM82");
                    eiInfo.Set("method", "insert");

                    //主表新增block
                    this.BaseBlock(eiInfo);
                    //列表新增下一步block
                    this.SubBlock(eiInfo);

                    eiInfo.Set("planType", "无计划领用");
                    eiInfo.Set("lessMoney", this.LessMoney.Value);
                    eiInfo.Set("Money", this.Money.Value);

                    base.Submit(eiInfo, DoCommitCompleted);
                }
            }
            else
            {
                this.OpenEFWindowAlert(msg, true);
                return;
            }

        }

        /// <summary>
        /// 执行上报动作
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Reported_Click(object sender, RoutedEventArgs e)
        {
            Button button = sender as Button;
            button.IsEnabled = false;
            TempButton = button;
            String msg = "1";
            IList<EIRow> _list = this.sub_grid.GetCheckedEIRows() == null ? new List<EIRow>() : this.sub_grid.GetCheckedEIRows();
            IList<EIRow> noplan_list = null;
            if (this.noplansub_grid.EIBlock != null)
            {
                noplan_list = this.noplansub_grid.EIBlock.GetRows();
            }
            
            if (this.LessMoney.Value.ToString() == "0")
            {
                msg = "用户已经无材料费用额度，请通知相关部门调整费用额度！";
            }
            else if (this.RESULT.Visibility == Visibility.Visible && _list.Count <= 0)
            {
                msg = "请选择需要申请上报的数据明细！";
            }
            else if (this.NOPLANRESULT.Visibility == Visibility.Visible && noplan_list.Count <= 0)
            {
                msg = "请增加领料申请数据明细！";
            }
            //else
            //{
            //    for (int i = 0; i < _list.Count; i++)
            //    {
            //        if (this.sub_grid.GetCheckedEIRows()[i]["fdApplyProject"] != null)
            //        {
            //            if (this.sub_grid.GetCheckedEIRows()[i]["fdApplyProject"].ToString() == "")
            //            {
            //                msg = "请选择适用工程！";
            //                break;
            //            }
            //        }
            //        else
            //        {
            //            msg = "请选择适用工程！";
            //            break;
            //        }
            //    }
            //}

            if (msg == "1")
            {
                if (this.RESULT.Visibility == Visibility.Visible)
                {
                    this.fdApplicationStatus.Value = "上报";
                    base.Submit(OperationMode.Insert, "ZMCM82", "insert", DataRange.CheckedItems, DoCommitCompleted, null);
                }
                else
                {
                    this.fdApplicationStatus.Value = "上报";
                    EIInfo eiInfo = new EIInfo();
                    eiInfo.Set("service", "ZMCM82");
                    eiInfo.Set("method", "insert");

                    //主表新增block
                    this.BaseBlock(eiInfo);
                    //列表新增下一步block
                    this.SubBlock(eiInfo);

                    eiInfo.Set("planType", "无计划领用");
                    eiInfo.Set("lessMoney", this.LessMoney.Value);
                    eiInfo.Set("Money", this.Money.Value);

                    base.Submit(eiInfo, DoCommitCompleted);
                }
                //DialogParameters param = this.ModelDialogParameters("Confirm", "确定上报所选择的记录？");
                //param.Closed = ReportedConfirmClosed;
                //EFWindow.Confirm(param);
            }
            else
            {
                this.OpenEFWindowAlert(msg, true);
                return;
            }

        }

        /// <summary>
        /// 执行查看,撤销操作
        /// </summary>
        private void Cancel_Click(object sender, RoutedEventArgs e)
        {
            CmesWindows _window = this.Parent as CmesWindows;
            _window.DialogResult = false;
            _window.Close();
        }

        /// <summary>
        /// 执行完新增操作的回调函数
        /// </summary>
        public override void DoCommitCompleted(object sender, DoWorkCompletedEventArgs e)
        {
            if (e.EIInfo.Status == -1)
            {
                String msg = "插入失败！";
                if (e.EIInfo.GetMsg() != null || e.EIInfo.GetMsg().Equals(""))
                {
                    msg = e.EIInfo.Msg;
                }
                base.OpenEFWindowAlert(msg, true);
                base.TempButtonOpen(true);
            }
            else
            {
                CmesWindows _window = this.Parent as CmesWindows;
                _window.DialogResult = true;
                _window.Close();
            }
        }

        /// <summary>
        /// 保存确认框，点击保存按钮执行事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        //private void SavedConfirmClosed(object sender, WindowClosedEventArgs e)
        //{
        //    if (e.DialogResult == null || !e.DialogResult.Value)
        //    {
        //        this.TempButtonOpen(true);//取消后，按钮生效
        //        return;
        //    }
        //    if (e.DialogResult.Value)
        //    {
        //        base.Submit(OperationMode.Insert, "ZMCM82", "insert", DataRange.CheckedItems, DoCommitCompleted, null);
        //    }
        //}

        /// <summary>
        /// 上报确认框，点击上报按钮执行事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        //private void ReportedConfirmClosed(object sender, WindowClosedEventArgs e)
        //{
        //    if (e.DialogResult == null || !e.DialogResult.Value)
        //    {
        //        this.TempButtonOpen(true);//取消后，按钮生效
        //        return;
        //    }
        //    if (e.DialogResult.Value)
        //    {
        //          base.Submit(OperationMode.Insert, "ZMCM82", "insert", DataRange.CheckedItems, DoCommitCompleted, null);
        //    }
        //}

        /// <summary>
        /// 列表数据编辑结束后执行
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void sub_grid_CellEditEnded(object sender, GridViewCellEditEndedEventArgs e)
        {
            EFGridTextColumn column = e.Cell.Column as EFGridTextColumn;
            if (column != null)
            {
                if (column.eColumnName.Equals("fdApplicationNumber"))
                {
                    UIBaseEntity obj = e.Cell.ParentRow.DataContext as UIBaseEntity;
                    EIRow row = obj.GetEIRow();
                    var price = row["fdPrice"];
                    row["fdApplicationSum"] = Convert.ToDouble(price) * Convert.ToDouble(row["fdApplicationNumber"]);
                }
            }
        }

        private void QueryClick(object sender, RoutedEventArgs e)
        {
            EIInfo eiInfo = new EIInfo();
            eiInfo.Set("service", "ZMCM82");
            eiInfo.Set("method", "query");
            EIBlock block = eiInfo.AddBlock(EIConstants.QueryStatusBlock);

            EIRow row = new EIRow();
            EIColumn column = new EIColumn();
            column.SetName("fdYear");
            block.AddColumn(column);
            row.Add("fdYear", this.fdYear.Value);

            column = new EIColumn();
            column.SetName("fdMonth");
            block.AddColumn(column);
            row.Add("fdMonth", this.fdMonth.Value);

            column = new EIColumn();
            column.SetName("fdApplicationDepartment");
            block.AddColumn(column);
            row.Add("fdApplicationDepartment", this.fdApplicationDepartment.Value);

            if (this.inqufdMaterialName.Value != null && !this.inqufdMaterialName.Value.Equals(""))
            {
                column = new EIColumn();
                column.SetName("fdMaterialName");
                block.AddColumn(column);

                row.Add("fdMaterialName", this.inqufdMaterialName.Value);
            }

            if (this.inqufdMaterialCode.Value != null && !this.inqufdMaterialCode.Value.Equals(""))
            {
                column = new EIColumn();
                column.SetName("fdMaterialCode");
                block.AddColumn(column);

                row.Add("fdMaterialCode", this.inqufdMaterialCode.Value);
            }

            if (this.inqufdSpecModel.Value != null && !this.inqufdSpecModel.Value.Equals(""))
            {
                column = new EIColumn();
                column.SetName("fdSpecModel");
                block.AddColumn(column);

                row.Add("fdSpecModel", this.inqufdSpecModel.Value);
                
            }

            block.AddRow(row);

            HttpServiceAgent agent = new HttpServiceAgent();
            agent.CallService(eiInfo, OnDoQueryCompleted);
        }

        /// <summary>
        /// 查询后的回调方法
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnDoQueryCompleted(object sender, DoWorkCompletedEventArgs e)
        {
            if (e.EIInfo.GetStatus() != -1)
            {
                this.sub_grid.UpdateData(e.EIInfo);
            }
        }

        /// <summary>
        /// 根据物资编码的值，给其他文本框赋值
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void fdMaterialCode_ValueChanged(object sender, ValueChangedEventArgs e)
        {
            if (e.NewValue == null && e.OldValue.Equals(""))
            {
                return;
            }

            EFDataField field = sender as EFDataField;
            CmesCustomView picker = field.Content as CmesCustomView;

            if (picker.ItemObject != null)
            {
                if (!picker.ItemObject.Equals(""))
                {
                    this.fdMaterialCode.Value = picker.ItemObject.GetType().GetProperty("fdMaterialCode").GetValue(picker.ItemObject, null) as string;
                    this.fdMaterialName.Value = picker.ItemObject.GetType().GetProperty("fdMaterialName").GetValue(picker.ItemObject, null) as string;
                    this.fdMetric.Value = picker.ItemObject.GetType().GetProperty("fdMetric").GetValue(picker.ItemObject, null) as string;
                    this.fdSpecModel.Value = picker.ItemObject.GetType().GetProperty("fdSpecModel").GetValue(picker.ItemObject, null) as string;
                    this.fdNumber.Value = picker.ItemObject.GetType().GetProperty("fdNumber").GetValue(picker.ItemObject, null) as string;
                    this.fdQuality.Value = picker.ItemObject.GetType().GetProperty("fdQuality").GetValue(picker.ItemObject, null) as string;

                    this.fdMaterialId.Value = picker.ItemObject.GetType().GetProperty("fdKeyId").GetValue(picker.ItemObject, null) as string;
                    this.fdPrice.Value = picker.ItemObject.GetType().GetProperty("fdPrice").GetValue(picker.ItemObject, null);

                }
                //没选中时赋予空字符串
                else
                {
                    this.fdMaterialCode.Value = "";
                    this.fdMaterialName.Value = "";
                    this.fdMetric.Value = "";
                    this.fdSpecModel.Value = "";
                    this.fdNumber.Value = "";
                    this.fdQuality.Value = "";

                    this.fdMaterialId.Value = "";
                    this.fdPrice.Value = 0;
                }

                string fdPrice = String.IsNullOrEmpty(this.fdPrice.Value.ToString()) ? "0" : this.fdPrice.Value.ToString();
                string fdApplicationNumber = String.IsNullOrEmpty(this.fdApplicationNumber.Value.ToString()) ? "0" : this.fdApplicationNumber.Value.ToString();
                this.fdApplicationSum.Value = Double.Parse(fdPrice) * Double.Parse(fdApplicationNumber);
            }
        }

        /// <summary>
        /// 实收金额等于实进数量乘以单价
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void fdApplicationNumber_ValueChanged(object sender, ValueChangedEventArgs e)
        {
            if (this.fdApplicationNumber.Validate())
            {
                string fdPrice = String.IsNullOrEmpty(this.fdPrice.Value.ToString()) ? "0" : this.fdPrice.Value.ToString();
                string fdApplicationNumber = String.IsNullOrEmpty(this.fdApplicationNumber.Value.ToString()) ? "0" : this.fdApplicationNumber.Value.ToString();

                if (e.NewValue != null)
                {
                    if (this.fdPrice.Validate() && this.fdApplicationNumber.Validate())
                    {
                        this.fdApplicationSum.Value = Double.Parse(fdPrice) * Double.Parse(fdApplicationNumber);
                    }
                }
            }
        }

        /// <summary>
        /// 将新增页面中的录入信息组织成一个block
        /// </summary>
        /// <param name="eiInfo"></param>
        private void BaseBlock(EIInfo eiInfo)
        {
            EFViewCmesProperty _view = new EFViewCmesProperty();
            _view.DataFields = this.InsertGrid.GetChildObjects<EFDataField>(null, true);
            base.ViewProperty = _view;

            EIBlock baseBlock = new EIBlock("inqu_status");
            baseBlock.SetColumns(base.GetDataFieldColumns("inqu_status"));
            EIColumn column = new EIColumn();
            column.SetName("fdApplicationDepartment");
            baseBlock.AddColumn(column);

            column = new EIColumn();
            column.SetName("fdApplicationStatus");
            baseBlock.AddColumn(column);

            EIRow row = base.GetDataFieldValues("inqu_status");
            row.Add("fdApplicationDepartment", this.fdApplicationDepartment.Value);
            row.Add("fdApplicationStatus", this.fdApplicationStatus.Value);

            baseBlock.AddRow(row);
            eiInfo.AddBlock(baseBlock);
        }

        /// <summary>
        /// 将列表中的记录组织成一个block
        /// </summary>
        /// <param name="eiInfo"></param>
        private void SubBlock(EIInfo eiInfo)
        {
            EIBlock subBlock = new EIBlock("result");
            subBlock.SetColumns(this.noplansub_grid.EIBlock.GetColumns());
            subBlock.SetRows(this.noplansub_grid.EIBlock.GetRows());
            eiInfo.AddBlock(subBlock);
        }
    }
}
